
//
//  UIButton+Category.m
//  我的微博
//
//  Created by tom-1 on 15/12/6.
//  Copyright © 2015年 tom-1. All rights reserved.
//

#import "UIButton+Category.h"

@implementation UIButton (Category)
- (UIButton *)initWithImageNameBackImageName:(NSString *)imageName backImageName:(NSString *)backImageName {
    UIButton *btn = [[UIButton alloc] init];
    NSString *hltImageName = [NSString stringWithFormat:@"%@_highlighted",imageName];
    NSString *hltBackImageName = [NSString stringWithFormat:@"%@_highlighted",backImageName];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    
    [btn setImage:[UIImage imageNamed:hltImageName] forState:UIControlStateHighlighted];
    
    [btn setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal];
    
    [btn setBackgroundImage:[UIImage imageNamed:hltBackImageName] forState:UIControlStateHighlighted];
    
    [btn sizeToFit];
    
    return btn;
}

+ (UIButton *)buttonWithColorImageTitle:(NSString *)title color:(UIColor *)color image:(NSString *)image {
    UIButton *btn = [[UIButton alloc] init];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    return btn;
}
@end
